export default function renderTemplate(tokens, data) {
  let res = ''
  for (let i = 0; i < tokens.length; i++) {
    let token = tokens[i]
    if (token[0] == 'text') {
      res += token[1]
    } else if (token[0] == 'name') {
      res += token[1] == '.' ? data : data[token[1]]
    } else if (token[0] == '#') {
      let arr = data[token[1]]
      for (let j = 0; j < arr.length; j++) {
        res += renderTemplate(token[2], arr[j])
      }
    }
  }
  return res
}
